import axios from "axios";

const service = axios.create({
  baseURL: "http://10.10.1.40:8225",
  timeout: 5000,
});

// 请求拦截
service.interceptors.request.use(
  (config) => {
    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
);
/* 响应拦截 */
service.interceptors.response.use(
  (response) => {
    const res = response.data
    if (res.status !== 200) {
      return Promise.reject(error)
    } else {
      return response
    }
  },
  (error) => {
    const errMsg = error?.response?.data?.msg
    error.message = errMsg
    return Promise.reject(error)
  }
)

export default service;
